/**
 * Created by Cyril on 16/8/17.
 */
export default class Store {
  static get (key) {
    var dataString = localStorage.getItem(key)
    if (!dataString) {
      return undefined
    } else {
      var data
      try {
        data = JSON.parse(dataString)
      } catch (err) {
        // eslint-disable-next-line
        data = eval('(' + dataString + ')')
      }
      return data
    }
  }

  static delete (key) {
    localStorage.removeItem(key)
  }

  static remove (key) {
    localStorage.removeItem(key)
  }

  static set (key, value) {
    localStorage.setItem(key, JSON.stringify(value))
  }
}
